/**
 * 题目难度工具
 */

/**
 * 获取难度对应的标签类型
 * @param {string} difficulty - 难度值
 * @returns {string}
 */
export function getDifficultyType(difficulty) {
  const map = {
    easy: 'success',
    medium: 'warning',
    hard: 'danger'
  }
  return map[difficulty] || 'info'
}

/**
 * 获取难度对应的颜色
 * @param {string} difficulty - 难度值
 * @returns {string}
 */
export function getDifficultyColor(difficulty) {
  const map = {
    easy: '#67c23a',
    medium: '#e6a23c',
    hard: '#f56c6c'
  }
  return map[difficulty] || '#909399'
}

/**
 * 获取难度对应的中文文本
 * @param {string} difficulty - 难度值
 * @returns {string}
 */
export function getDifficultyText(difficulty) {
  const map = {
    easy: '简单',
    medium: '中等',
    hard: '困难'
  }
  return map[difficulty] || difficulty
}

/**
 * 将前端难度值映射为后端难度值
 * @param {string} difficulty - 前端难度值
 * @returns {string}
 */
export function mapDifficultyToBackend(difficulty) {
  if (!difficulty || typeof difficulty !== 'string') {
    return ''
  }
  const map = {
    easy: '简单',
    medium: '中等',
    hard: '困难'
  }
  return map[difficulty] || difficulty
}

/**
 * 将后端难度值映射为前端难度值
 * @param {string} difficulty - 后端难度值
 * @returns {string}
 */
export function mapDifficultyToFrontend(difficulty) {
  if (!difficulty || typeof difficulty !== 'string') {
    return 'easy'
  }
  const map = {
    简单: 'easy',
    中等: 'medium',
    困难: 'hard'
  }
  return map[difficulty] || 'easy'
}
